package com.ocean.controller.library;

import com.ocean.entity.library.Record;
import com.ocean.service.library.RecordService;
import com.ocean.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * Project：SchoolManage
 * Package：com.ocean.controller.library
 * Author:zy
 * Time:2023/3/3
 */

@RestController
@RequestMapping("/api/library/record")
public class RecordController {
    @Autowired
    private RecordService recordService;

    @RequestMapping("save.do")
    public R save(@RequestBody Record record){
        return recordService.save(record);
    }

    @RequestMapping("del.do")
    public R del(int id){
        return recordService.del(id);
    }

    @RequestMapping("update.do")
    public R update(@RequestBody Record record){
        return recordService.update(record);
    }


    @RequestMapping("querypage.do")
    public R queryPage(int page,int size){
        return recordService.queryPage(page, size);
    }

    @PostMapping("import.do")
    public R importData(MultipartFile file){
        return recordService.importData(file);
    }

    @GetMapping("export.do")
    public void exportData(HttpServletResponse response){
        recordService.exportData(response);
    }

    @GetMapping("echartsStu.do")
    public R echarts1(){
        return recordService.queryEchartsStu();
    }

    @GetMapping("echartsBook.do")
    public R echarts2(){
        return recordService.queryEchartsBook();
    }
}
